package com.idealighter.game.games.doudizhu.job;

import com.idealighter.game.games.doudizhu.manager.DouDiZhuMgr;
import com.idealighter.game.games.doudizhu.struct.DouDiZhuRoom;
import com.idealighter.game.server.context.ApplicationContext;

import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;

/**
 * 斗地主比赛job .
 * 
 * @date 2016年2月29日 下午12:00:46
 *
 */
public class DouDiZhuMatchJob implements Job {

  @Override
  public void execute(JobExecutionContext context) throws JobExecutionException {
    DouDiZhuRoom room = (DouDiZhuRoom) context.getJobDetail().getJobDataMap().get("room");
    DouDiZhuMgr douDiZhuMgr = ApplicationContext.getBean(DouDiZhuMgr.class);
    douDiZhuMgr.gameExecutor.execute(() -> {
      douDiZhuMgr.startMatch(room.curMatch);
      douDiZhuMgr.scheduleNextTimerMatch(room, context.getNextFireTime().getTime());
    });
  }

}
